package com.homeparking.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homeparking.common.annotation.Log;
import com.homeparking.common.core.controller.BaseController;
import com.homeparking.common.core.domain.AjaxResult;
import com.homeparking.common.enums.BusinessType;
import com.homeparking.manage.domain.ManageDeveloper;
import com.homeparking.manage.service.IManageDeveloperService;
import com.homeparking.common.utils.poi.ExcelUtil;
import com.homeparking.common.core.page.TableDataInfo;

/**
 * 开发商Controller
 * 
 * @author liuyangyang
 * @date 2025-10-12
 */
@RestController
@RequestMapping("/manage/manage_developer")
public class ManageDeveloperController extends BaseController
{
    @Autowired
    private IManageDeveloperService manageDeveloperService;

    /**
     * 查询开发商列表
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManageDeveloper manageDeveloper)
    {
        startPage();
        List<ManageDeveloper> list = manageDeveloperService.selectManageDeveloperList(manageDeveloper);
        return getDataTable(list);
    }

    /**
     * 导出开发商列表
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:export')")
    @Log(title = "开发商", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageDeveloper manageDeveloper)
    {
        List<ManageDeveloper> list = manageDeveloperService.selectManageDeveloperList(manageDeveloper);
        ExcelUtil<ManageDeveloper> util = new ExcelUtil<ManageDeveloper>(ManageDeveloper.class);
        util.exportExcel(response, list, "开发商数据");
    }

    /**
     * 获取开发商详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:query')")
    @GetMapping(value = "/{developerId}")
    public AjaxResult getInfo(@PathVariable("developerId") String developerId)
    {
        return success(manageDeveloperService.selectManageDeveloperByDeveloperId(developerId));
    }

    /**
     * 新增开发商
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:add')")
    @Log(title = "开发商", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageDeveloper manageDeveloper)
    {
        return toAjax(manageDeveloperService.insertManageDeveloper(manageDeveloper));
    }

    /**
     * 修改开发商
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:edit')")
    @Log(title = "开发商", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageDeveloper manageDeveloper)
    {
        return toAjax(manageDeveloperService.updateManageDeveloper(manageDeveloper));
    }

    /**
     * 删除开发商
     */
    @PreAuthorize("@ss.hasPermi('manage:manage_developer:remove')")
    @Log(title = "开发商", businessType = BusinessType.DELETE)
	@DeleteMapping("/{developerIds}")
    public AjaxResult remove(@PathVariable String[] developerIds)
    {
        return toAjax(manageDeveloperService.deleteManageDeveloperByDeveloperIds(developerIds));
    }
}
